Once I get that upgrade to 36-hour days, I will tackle that. – Mychaeel

Legacy:Modifying Vehicle Weapons/Discussion

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

LionsPhil: Wouldn't subclassing the vehicle be a much better approach? I've now tested it, and you can do it with a very minimalist class – here's a trivial one which defines a Scorpion with a Goliath's main gun (!):

class ONSRVArmouredCar extends ONSRV;
defaultproperties {
  DriverWeapons(0)=(WeaponClass=class'Onslaught.ONSHoverTankCannon',WeaponBone=ChainGunAttachment);
}

Not only is this less work, it's the Right Thing from an OO perspective, and will continue to track any changes (bugfixes!) or additions Epic make to ONSRV.

Blip2: I agree, for small changes but bigger changes (and ones where you take out code) you would need to create a completely new vehicle - I will build it in later

Swifty: The above code didn't work when I tried it. Having been unable to summon it ingame, I tried placing it straight into a map in UnrealEd. It appeared fine in all views of UnrealEd, yet when I ran the map, it simply wasn't there. No collision, no shadow, no nothing. Any ideas why? Pretty sure I haven't mistyped the code or anythign dumb like that :P

Blip2: what were you typing to try to summon it? and how would you just place it - its code and is not placeable? or did you write an onsfactory for it too?

AlexKotsch: I'm new to the Wiki and Programming, but I still have a suggestion. You can make any primary vehicle weapon into a secondary (pawn), to do this, make a new file (eg. ONSHoverTankCannonPawn) copy this code and replace HoverTankCannon with the weapon name of your choice, and change the strings if you want.

//-----------------------------------------------------------
class ONSHoverTankCannonPawn extends ONSWeaponPawn;
 
defaultproperties
{
     GunClass=Class'MyPackage.ONSHoverTankCannon'
     CameraBone="TankTurret"
     bDrawDriverInTP=False
     ExitPositions(0)=(Y=-365.000000,Z=200.000000)
     ExitPositions(1)=(Y=365.000000,Z=200.000000)
     ExitPositions(2)=(Y=-365.000000,Z=-100.000000)
     ExitPositions(3)=(Y=365.000000,Z=-100.000000)
     EntryPosition=(Z=-150.000000)
     EntryRadius=130.000000
     FPCamViewOffset=(X=5.000000,Z=35.000000)
     TPCamDistance=100.000000
     TPCamLookat=(X=0.000000,Z=110.000000)
     DriverDamageMult=0.100000
     VehiclePositionString="in a Tank Turret"
     VehicleNameString="Tank Turret"
}

Also make the camera bone the same as the GunnerAttachmentBone in the ONSWeapon code (eg. ONSHoverTankCannon), which you have to add. The bone is the same as the YawBone and goes under default properties.

defaultproperties
{
     YawBone="TankTurret"
     PitchBone="TankBarrel"
     PitchUpLimit=6000
     PitchDownLimit=61500
     WeaponFireAttachmentBone="TankBarrel"
     GunnerAttachmentBone="TankTurret"          //make this one.
     WeaponFireOffset=200.000000

Dont forget to save the edited ONSWeapon in a different file (eg. MyPackage/Classes).

It worked for me, I made a Hummer H5 Mad Max Version, it has a Goliath Cannon Turret on the top of it.